# 开发人员：mj
# 开发日期：2020/6/21
# 开发时间：19:58
# 开发环境：PyCharm
#打印三角形
'''第一种方法'''
def triangle(x=12):
    num=int(x)
    for i in range(1,num+1):
        for j in range(num-i):
            print("{:>2}".format(' '),sep=' ',end=' ')
        for j in range(i,0,-1):
            print("{:>2}".format(j),sep='  ',end=' ')
        print('\n')
triangle(x=12)

'''第二种方法'''

def triangle1(x):
    num=int(x)
    for i in range(1,num+1):
        for j in range(num,0,-1):
            if i<j:
                print("{:>3}".format(" "),sep='   ',end='  ')
            else:
                print("{:>3}".format(j),sep='   ',end='  ')
        print('\n')
triangle1(x=12)
def triangle3(x):
    num=int(x)
    for i in range(1,num+1):
        for j in range(num,0,-1):
            if i<j:
                print("{:>3}".format(" "),sep='   ',end='  ')
            else:
                print("{:>3}".format(j),sep='   ',end='  ')
        print('\n')
triangle1(x=12)


'''第三种方法'''

def triangle2(x):
    i=1
    j=int(x)
    def printriangle():
        print("{:>3}".format(" "), sep='   ', end='  ')
    def printriangle1(num):
        print("{:>3}".format(num), sep='   ', end='  ')
    while True:
        if i < j and j!=0:
            printriangle()
            j=j-1
        elif i>=j and j!=0:
            printriangle1(j)
            j=j-1
        elif j==0 and i!=int(x):
            i=i+1
            j=int(x)
            print('\n')
        elif i==int(x):
            break
triangle2(x=12)


# 前后间距不同
